package com.qezhhnjy.mall.ware.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qezhhnjy.mall.common.entity.ware.WareOrderTaskDetail;
import com.qezhhnjy.mall.common.http.BaseResult;
import com.qezhhnjy.mall.ware.service.WareOrderTaskDetailService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 库存工作单 前端控制器
 * </p>
 *
 * @author qezhhnjy
 * @since 2021-06-27
 */
@RestController
@Api(tags = "库存工作单接口")
@Slf4j
@RequestMapping("/ware-order-task-detail")
public class WareOrderTaskDetailController {
    @Resource
    private WareOrderTaskDetailService wareOrderTaskDetailService;

    @GetMapping("/get")
    @Operation(summary = "根据id获取库存工作单信息")
    public BaseResult<WareOrderTaskDetail> get(Long id) {
        WareOrderTaskDetail wareOrderTaskDetail = wareOrderTaskDetailService.getById(id);
        return BaseResult.success(wareOrderTaskDetail);
    }

    @PostMapping("/save")
    @Operation(summary = "新增库存工作单信息")
    public BaseResult<WareOrderTaskDetail> save(@RequestBody WareOrderTaskDetail wareOrderTaskDetail) {
        wareOrderTaskDetailService.save(wareOrderTaskDetail);
        return BaseResult.success(wareOrderTaskDetail);
    }

    @PutMapping("/update")
    @Operation(summary = "更新库存工作单信息")
    public BaseResult<WareOrderTaskDetail> update(@RequestBody WareOrderTaskDetail wareOrderTaskDetail) {
        wareOrderTaskDetailService.updateById(wareOrderTaskDetail);
        return BaseResult.success(wareOrderTaskDetail);
    }

    @PostMapping("/page")
    @Operation(summary = "分页获取库存工作单信息")
    public BaseResult<Page<WareOrderTaskDetail>> page(@RequestBody Page<WareOrderTaskDetail> page) {
        wareOrderTaskDetailService.page(page);
        return BaseResult.success(page);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "根据id删除库存工作单信息")
    public BaseResult<Long> delete(Long id) {
        wareOrderTaskDetailService.removeById(id);
        return BaseResult.success(id);
    }
}

